import 'package:flutter/material.dart';
import './styleManager.dart';
/*
    todo Row当中 左右对齐如何简单实现 ??
*/
Widget buildItem(BuildContext context,int index){
       return new Container(
            child: new Column(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                new Divider(),//1像素分割线
                getTitle(),
                new Divider(),
                getListTitle(),
                new Divider(),
                getBottom(),
                new Divider(),
              ],
            ),
       );
}

//获取ListView Item的头部分
Widget getTitle(){
   return new Container(
      padding: styleManager.padding_title,
      child:  new Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          new Expanded(
              flex:1,
              child: new Text("订单编号：",style: styleManager.order_black)),
          new Expanded(
              flex: 1,
              child:  new Text("11977240",style: styleManager.order_black)),
          new Expanded(
              flex: 1,
              child:  new Text("", style: styleManager.order_black)),
          new Expanded(
              flex: 1,
              child:  new Text("",style: styleManager.order_black)),
          new Expanded(
              flex: 1,
              child: new Text("等待付款",style:styleManager.order_red),

              )
        ],
      ),
   );
}
//获取ListView Item的中间部分
Widget getListTitle(){
  return new ListTile(
      isThreeLine: true,
      dense: false,
      leading: new Image.asset('lib/icon/icon.jpg',width: styleManager.ImageWidth,height: styleManager.ImageHeight),
      title: new Text('商品名称',style: styleManager.order_black),
      subtitle: new Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          new Text('肤色/M',style: styleManager.order_black),
          new Text('￥99',style:styleManager.order_red)
        ],
      ),
      trailing: new Text('x1',style: styleManager.order_green),
  );
}
//获取ListView Item的底部部分
Widget getBottom(){
  return new Container(
    padding: styleManager.padding_bottom,
    child:  new Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: <Widget>[
        new Expanded(
            flex:2,
            child: new Text("应付金额：",style: styleManager.order_black)),
        new Expanded(
            flex: 2,
            child:  new Text("￥180",style: styleManager.order_black)),
        new Expanded(
            flex: 3,
            child:  new Container(
              //height: 25,
              //todo button的宽度 如何调整 ?
              child:  new OutlineButton  (
                child: new Text("取消订单",style: styleManager.order_black),
              )
            )
        ),
        new Expanded(
            flex: 3,
            child: new Container(
              child:  OutlineButton  (
                child: new Text("立即付款",style: styleManager.order_red),
              ),
            )
        )
      ],
    ),
  );
}
